import numpy as np


def euclidean(p1, p2):
    return np.linalg.norm(np.array(p1) - np.array(p2))

def compute_cost_matrix(usvs, tasks, lambda_weight=0.1):
    n_usvs = len(usvs)
    n_tasks = len(tasks)
    cost_matrix = np.full((n_usvs, n_tasks), np.inf)

    for i, usv in enumerate(usvs):
        for j, task in enumerate(tasks):
            if usv['max_load'] < task['load']:
                continue
            dist = euclidean(usv['pos'], task['start_port']) + euclidean(task['start_port'], task['end_port'])
            redundancy = usv['max_load'] - task['load']
            cost_matrix[i][j] = dist + lambda_weight * redundancy
    return cost_matrix
